ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
freemaster_rec.c File Reference

FreeMASTER Recorder implementation. More...

#include "freemaster.h"
#include "freemaster_private.h"
#include "freemaster_protocol.h"
#include "freemaster_rec.h"

Defines

#define CMP(v, t)   ((FMSTR_BOOL)(((v) < (t)) ? 0 : 1))
 Compare macro used in trigger detection.

Typedefs

typedef FMSTR_BOOL(* FMSTR_PCOMPAREFUNC )(void)

Functions

void FMSTR_InitRec (void)
 Recorder Initialization.
void FMSTR_AbortRec (void)
 Abort and de-initialize recorder.
void FMSTR_SetUpRecBuff (FMSTR_ADDR pBuffer, FMSTR_SIZE nBuffSize)
 API: Replacing the recorder buffer with the user's one.
FMSTR_BPTR FMSTR_SetUpRec (FMSTR_BPTR pMessageIO)
 Handling SETUPREC and SETUPREC_EX commands.
void FMSTR_TriggerRec (void)
 API: Pull the trigger of the recorder.
FMSTR_BPTR FMSTR_StartRec (FMSTR_BPTR pMessageIO)
 Handling STARTREC command.
FMSTR_BPTR FMSTR_StopRec (FMSTR_BPTR pMessageIO)
 Handling STOPREC command.
FMSTR_BPTR FMSTR_GetRecStatus (FMSTR_BPTR pMessageIO)
 Handling GETRECSTS command.
FMSTR_SIZE FMSTR_GetRecBuffSize ()
 Get recorder memory size.
FMSTR_BOOL FMSTR_IsInRecBuffer (FMSTR_ADDR dwAddr, FMSTR_SIZE8 nSize)
 Check wether given memory region is inside the recorder buffer.
FMSTR_BPTR FMSTR_GetRecBuff (FMSTR_BPTR pMessageIO)
 Handling GETRECBUFF and GETRECBUFF_EX command.
void FMSTR_Recorder (void)
 API: Recorder worker routine - can be called from application's timer ISR.

Variables

FMSTR_U16 pcm_wRecTotalSmps
FMSTR_U16 pcm_wRecPostTrigger
FMSTR_U8 pcm_nRecTriggerMode
FMSTR_U16 pcm_wRecTimeDiv
FMSTR_U8 pcm_nRecVarCount
FMSTR_ADDR pcm_pRecVarAddr [FMSTR_MAX_SCOPE_VARS]
FMSTR_SIZE8 pcm_pRecVarSize [FMSTR_MAX_SCOPE_VARS]
FMSTR_U16 pcm_wRecTimeDivCtr
FMSTR_U16 pcm_wStoprecCountDown
FMSTR_REC_FLAGS pcm_wRecFlags
FMSTR_U16 pcm_wRecBuffStartIx
FMSTR_ADDR pcm_dwRecWritePtr
FMSTR_ADDR pcm_dwRecEndBuffPtr

Detailed Description

FreeMASTER Recorder implementation.

Version:
1.0.24.0
Date:
Aug-3-2011

Define Documentation

#define CMP (   v,
 
)    ((FMSTR_BOOL)(((v) < (t)) ? 0 : 1))

Compare macro used in trigger detection.

Parameters:
v- original command
t- response buffer
Returns:
zero when value is lower than threshold.
non-zero when value is greater than or equal as threshold

Function Documentation

FMSTR_BPTR FMSTR_GetRecBuff ( FMSTR_BPTR  pMessageIO)

Handling GETRECBUFF and GETRECBUFF_EX command.

Parameters:
pMessageIO- original command (in) and response buffer (out)
Returns:
As all command handlers, the return value should be the buffer pointer where the response output finished (except checksum)

This function returns recorder buffer information

FMSTR_SIZE FMSTR_GetRecBuffSize ( void  )

Get recorder memory size.

Returns:
Recorder memory size in native sizeof units (=bytes on most platforms)
FMSTR_BPTR FMSTR_GetRecStatus ( FMSTR_BPTR  pMessageIO)

Handling GETRECSTS command.

Parameters:
pMessageIO- original command (in) and response buffer (out)
Returns:
As all command handlers, the return value should be the buffer pointer where the response output finished (except checksum)

This function returns current recorder status

FMSTR_BOOL FMSTR_IsInRecBuffer ( FMSTR_ADDR  dwAddr,
FMSTR_SIZE8  nSize 
)

Check wether given memory region is inside the recorder buffer.

Parameters:
dwAddr- address of the memory to be checked
wSize- size of the memory to be checked
Returns:
This function returns non-zero if user space is in recorder buffer

This function is called as a part of TSA-checking process when the PC host is requesting memory contents

void FMSTR_Recorder ( void  )

API: Recorder worker routine - can be called from application's timer ISR.

This returns quickly if recorder is not running, otherwise it calls quite lengthy recorder routine which does all the recorder work (sampling, triggering)

FMSTR_BPTR FMSTR_SetUpRec ( FMSTR_BPTR  pMessageIO)

Handling SETUPREC and SETUPREC_EX commands.

Parameters:
pMessageIO- original command (in) and response buffer (out)
Returns:
As all command handlers, the return value should be the buffer pointer where the response output finished (except checksum)
void FMSTR_SetUpRecBuff ( FMSTR_ADDR  pBuffer,
FMSTR_SIZE  nBuffSize 
)

API: Replacing the recorder buffer with the user's one.

Parameters:
pBuffer- user buffer pointer
wBuffSize- buffer size
Note:
Use the FMSTR_SetUpBuff32 to pass the forced 32bit address in SDM
FMSTR_BPTR FMSTR_StartRec ( FMSTR_BPTR  pMessageIO)

Handling STARTREC command.

Parameters:
pMessageIO- original command (in) and response buffer (out)
Returns:
As all command handlers, the return value should be the length of the response filled into the buffer (including status byte)

This function starts recording (initializes internal recording variables and flags)

FMSTR_BPTR FMSTR_StopRec ( FMSTR_BPTR  pMessageIO)

Handling STOPREC command.

Parameters:
pMessageIO- original command (in) and response buffer (out)
Returns:
As all command handlers, the return value should be the length of the response filled into the buffer (including status byte)

This function stops recording (same as manual trigger)

void FMSTR_TriggerRec ( void  )

API: Pull the trigger of the recorder.

This function starts the post-trigger stop countdown